package com.kx.kxblog.enums;

import com.kx.kxblog.bean.Result;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
@ApiModel(value = "ResultCode", description = "结果码")
public enum ResultCode{
    @ApiModelProperty(value = "0（成功）")
    SUCCESS(0, "操作成功"),
    FAIELD(1,"请求失败"),
    PARAMETER_ERROR(2,"参数错误"),
    SYSTEM_ERROR(100,"系统发生错误"),
    // 1x 错误相关
    // 3x 权限相关
    NO_PERMISSION(40,"没有权限"),
    UNLOGIN(41, "请先登录"),
    DATA_NOT_EXISTS(101,"数据不存在"),
    DATA_EXISTS(102,"数据已存在"),
    PASSWORD_INCORRECT(103, "密码不正确"),
    ;
    private final int code;
    private final String msg;

    public Result<Object> getResult(){
        return new Result<>(code, msg);
    }
    public <T> Result<T> getResult(T data){
        return new Result<>(code, msg, data);
    }
}